//
//  ViewController.m
//  AModule
//
//  Created by 神州锐达 on 2018/1/16.
//  Copyright © 2018年 onePiece. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)remoteAPPBtnClick:(UIButton *)sender {

    NSString *str = @"LSD://LSDSearchViewController/LSDSearchViewController?name=remoteApp&k=a bbb  cc中文###///zhogn+-+++wen中文";

    NSString *charactersToEscape =@"`#%^() {}\"*+-[]|\\<>";
    NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];
    
    NSString *encodedUrl = [str stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
    NSLog(@"lsd_URLEncodedString = %@",[self lsd_URLEncodedString:str]);
    NSLog(@"encodedUrl = %@",encodedUrl);
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString:encodedUrl] options:@{UIApplicationOpenURLOptionsSourceApplicationKey : @YES}
                                                                             completionHandler:^(BOOL success) {
                                                    
                                                                                 NSLog(@"%zd",success);
                                                                             }];
    
}

-(NSString *)lsd_URLEncodedString:(NSString *)str{
    
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
    return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL,kCFStringEncodingUTF8));
#pragma clang diagnostic pop
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
